package com.UnionPayCenter.operation.enums;

import com.UnionPayCenter.account.enums.PayChannelEnum;
import com.UnionPayCenter.enums.CodeBaseEnum;
import com.UnionPayCenter.exception.ApiException;

/**
 * 运营活动激励类型
 */
public enum ActivityRewardTypeEnum implements CodeBaseEnum {

    //充值奖品类型: 1--优惠券，2--现金券，3--现金折扣
    //支付奖品类型: 4--优惠券，5--现金券
    //微信支付奖品类型: 6--优惠券，7--现金券

    /**
     * 优惠券
     */
    COUPONS(1, "优惠券", null),
    /**
     * 现金券，直接充值到赠送账户
     */
    CASH(2, "现金券", null),
    /**
     * 现金折扣，充值的时候直接折扣
     */
    CASH_DISCOUNT(3, "现金折扣", null),

    /**
     * 优惠券
     */
    PAY_COUPONS(4, "优惠券", PayChannelEnum.BALANCE_PAY),

    /**
     * 现金券，直接充值到赠送账户
     */
    PAY_CASH(5, "现金券", PayChannelEnum.BALANCE_PAY),

    /**
     * 微信支付
     */
    WECHAT_PAY_COUPONS(6, "优惠券", PayChannelEnum.WECHAT_PAY),

    /**
     * 微信支付
     */
    WECHAT_PAY_CASH(7, "现金券", PayChannelEnum.WECHAT_PAY),
    ;

    private int code;

    private String msg;

    private PayChannelEnum payChannel;

    ActivityRewardTypeEnum(int code, String msg, PayChannelEnum payChannel) {
        this.code = code;
        this.msg = msg;
        this.payChannel = payChannel;
    }

    public static ActivityRewardTypeEnum getEnum(int code) {
        for (ActivityRewardTypeEnum ele : ActivityRewardTypeEnum.values()) {
            if (ele.code == code) {
                return ele;
            }
        }
        throw new ApiException(404, "不正确的活动奖励类型");
    }

    @Override
    public int code() {
        return this.code;
    }

    @Override
    public String msg() {
        return msg;
    }

    public PayChannelEnum getPayChannel(){
        return this.payChannel;
    }
}
